import axios from '@/libs/api.request';

/**
 * 消息管理 相关接口
 */

// 获取审批流程表格列表接口
export const getFlowTabelList = (data) => {
  return axios.request({
    url: '/preset/pagelist',
    method: 'POST',
    data: data
  });
};

// 审批节点的审批名称下拉框
export const getFlowType = (data) => {
  return axios.request({
    url: `/dict/k?key=${data}`,
    method: 'POST'
  });
};

// 获取审批人员列表接口
export const getApproverLit = (data = {}) => {
  return axios.request({
    url: '/dict/chose',
    method: 'POST',
    data: data
  });
};

// 编辑/查看审批流程表格列表接口
export const getFlowInfo = (data) => {
  return axios.request({
    url: '/preset/edit?id=' + data,
    method: 'POST'
  });
};

// 增加审批节点
export const addFlowNode = data => {
  return axios.request({
    url: '/preset/addnode',
    method: 'POST',
    data: data
  });
};

// 删除审批节点
export const delFlowNode = data => {
  return axios.request({
    url: '/preset/delnode?nodeId=' + data,
    method: 'POST'
  });
};

// 生成一个默认流程
export const initProcessFlow = data => {
  return axios.request({
    url: '/preset/init',
    method: 'POST',
    data: data
  });
};

// 编辑node节点
export const unpdateFlowNode = data => {
  return axios.request({
    url: '/preset/updatenode',
    method: 'POST',
    data: data
  });
};

// 删除流程
export const delProcessFlow = data => {
  return axios.request({
    url: '/preset/del?id=' + data,
    method: 'POST'
  });
};

// 编辑流程
export const processEditSave = data => {
  return axios.request({
    url: '/preset/editsave',
    method: 'POST',
    data: data
  });
};

// 默认审批流程选择工序 查询所有工序
export const getWorkList = data => {
  return axios.request({
    url: '/pt/gx/search2',
    method: 'POST',
    data: data
  });
};

// 工序id查询工序名
export const getWorkNamefromIds = data => {
  return axios.request({
    url: '/pt/other/nodenames',
    method: 'POST',
    data: data
  });
};

// 查询合同段
export const getContractList = () => {
  return axios.request({
    url: '/pt/htdlist1',
    method: 'POST'
  });
};

// 查询单位工程
export const getDwList = data => {
  return axios.request({
    url: '/pt/dwlist',
    method: 'POST',
    data: data
  });
};

// 查询分部工程
export const getFbList = data => {
  return axios.request({
    url: '/pt/fblist',
    method: 'POST',
    data: data
  });
};

// 我的已办
export const getDoneList = data => {
  return axios.request({
    url: '/message/flowYb',
    method: 'POST',
    data: data
  });
};

// 我的发起
export const getInitiateList = data => {
  return axios.request({
    url: '/message/flowFq',
    method: 'POST',
    data: data
  });
};

// 我的待办
export const getTodoList = data => {
  return axios.request({
    url: '/message/flowDb',
    method: 'POST',
    data: data
  });
};

// 批量审批
export const muApproval = data => {
  return axios.request({
    url: '/message/batchOpinions',
    method: 'POST',
    data: data
  });
};

// 审批打回发起人
export const muApprovalBackFirst = data => {
  return axios.request({
    url: '/flow/backfirst',
    method: 'POST',
    data: data
  });
};

// 审批打回上一步
export const muApprovalBack = data => {
  return axios.request({
    url: '/flow/backstep',
    method: 'POST',
    data: data
  });
};

// 撤回流程
export const revokeFlow = data => {
  return axios.request({
    url: `/flow/revoke`,
    method: 'POST',
    data: data
  });
};
